package com.example.module_course.theme

import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ProvideTextStyle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Layout

@Composable
fun ComposeTheme(
    content: @Composable () -> Unit
) {
    MaterialTheme {
        // 设置全局参数，去除默认点击效果
        ProvideTextStyle(value = MaterialTheme.typography.bodyMedium) {
            content()
        }
    }
}

// 在使用时通过 Modifier 来去除点击效果
@Composable
fun NoRippleClickable(
    onClick: () -> Unit = {}, // 提供默认的 onClick 参数
    content: @Composable () -> Unit
) {
    Layout(
        content = content,
        modifier = Modifier.clickable(
            interactionSource = remember { MutableInteractionSource() }, // 创建一个可记忆的交互源
            indication = null, // 设置为 null 以禁用波纹效果
            onClick = onClick // 设置点击事件
        )
    ) { measurables, constraints ->
        // 自定义测量和布局逻辑，或者你可以使用现有的布局如 Box 等代替
        val placeables = measurables.map { it.measure(constraints) }
        layout(constraints.maxWidth, constraints.maxHeight) {
            placeables.forEach { placeable ->
                placeable.place(0, 0)
            }
        }
    }
}
